<!DOCTYPE html>
<html>
<head>
    <title>公式编辑器</title>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <script src="lib/jquery-1.11.0.min.js"></script>
    <script src="lib/kitygraph.all.min.js"></script>
    <script src="lib/kity-formula-render.all.min.js"></script>
    <script src="lib/kity-formula-parser.all.min.js"></script>
    <script src="lib/kityformula-editor.all.min.js"></script>
    <script>
        jQuery(function($) {
            if(document.body.addEventListener) {
                var factory = kf.EditorFactory.create($("#kfEditorContainer")[0], {
                    render: {
                        fontsize: 24
                    },
                    resource: {
                        path: "./resource/"
                    }
                });

                factory.ready( function ( KFEditor ) {
                    $( "#tips").remove();
                    var editor = parent.FORMULA_EDITOR_FORMULAR;
                    var img;
                    try {
                        img = editor.selection.getNode();
                    } catch(e) {
                    }
                    var imgLatex = img && $(img).attr('data-latex');

                    this.execCommand( "render", imgLatex || "\\placeholder" );
                    this.execCommand( "focus" );
                    window.kfe = this;
                });
            } else {
                $( "#tips").css( "color", "black" );
                $( "#tips").css( "padding", "10px" );
            }
        });
        function getData(callback) {
            if(kfe) {
                kfe.execCommand('get.image.data', function(data) {
                    var latex = kfe.execCommand('get.source');
                    callback(data.img, latex);
                });
            } else {
                callback(false)
            }
        }
    </script>
    <link rel="stylesheet" href="assets/styles/page.css">
    <link rel="stylesheet" href="assets/styles/base.css">
    <link rel="stylesheet" href="assets/styles/ui.css">
    <link rel="stylesheet" href="assets/styles/scrollbar.css">
</head>
<body>
    <div id="kfEditorContainer" class="kf-editor">
        <div id="tips" class="tips">
            <div id="loading"><img src="loading.gif" alt="loading" /></div>
        </div>
    </div>
</body>
</html>